<template>
    <div>
        <van-address-edit :area-list="areaList" show-postal show-set-default show-search-result
            :area-columns-placeholder="['请选择', '请选择', '请选择']" @save="onSave" @delete="onDelete" />
    </div>
</template>

<script>
import { addaddress } from "../../api/address"
import { areaList } from '@vant/area-data';
export default {
    data() {
        return {
            areaList: areaList,

        };
    },
    methods: {
        async onSave(val) {
            console.log(val);
            //  第一个参数 用户id  第二个是  val 数据地址数据
            //  用户id 在本地存储

            let userinfo = JSON.parse(localStorage.getItem('userInfo'))

            console.log(userinfo.id);
            let result = await addaddress(userinfo.id, val)
            console.log(result);
            if (result.status == 0) {
                this.$toast(result.message)
                this.$router.back()
            }
        },
        onDelete() {
            this.$toast('save');
        },

    },
}
</script>

<style lang="scss" scoped></style>